php order filename

33

<?php
    $a=array();
    if ($handle = opendir('.')) {
    while (false !== ($file = readdir($handle))) {
    if(preg_match("/\.doc$/", $file)) 
    $a[]=$file;
    }

    closedir($handle);

    }
    sort($a);
    foreach($a as $i){
    echo $i;
    }
?>

Comments

Submit
0 Comments